#ifndef _KEYWORDTYPE_H_
#define _KEYWORDTYPE_H_
#include "SimpleNode.h"
#include "ast/exprType.h"
#include "ast/NameTok.h"
class IVisitor;
class keywordType;
typedef QSharedPointer<keywordType> keywordTypePtr;

class keywordType: public SimpleNode
{
public:
    explicit keywordType(const NameTokPtr& arg, const exprTypePtr& value, bool afterstarargs, int nodeId=-1);
    virtual ~keywordType();
    
    
    NameTokPtr arg();
    void setArg(const NameTokPtr& arg);
    
    exprTypePtr value();
    void setValue(const exprTypePtr& value);
    
    bool afterstarargs();
    void setAfterstarargs(bool afterstarargs);
    
    
    virtual QString type() const;
    virtual QString toString() const;
    virtual void accept(IVisitor* visitor, const SimpleNodePtr& node);
    virtual void traverse(IVisitor* visitor);
private:
    NameTokPtr _arg;
    exprTypePtr _value;
    bool _afterstarargs;
};



typedef QListIterator<keywordTypePtr> KeywordTypePtrListIterator;

class KeywordTypeList: public QList<keywordTypePtr>
{
public:
    inline KeywordTypeList() { }
    inline explicit KeywordTypeList(keywordTypePtr i) { append(i); }
    inline KeywordTypeList(const KeywordTypeList &l) : QList<keywordTypePtr>(l) { }
    inline KeywordTypeList(const QList<keywordTypePtr> &l) : QList<keywordTypePtr>(l) { }

    inline KeywordTypeList operator+(const KeywordTypeList &other) const
    { KeywordTypeList n = *this; n += other; return n; }
    inline KeywordTypeList &operator<<(keywordTypePtr it)
    { append(it); return *this; }
    inline KeywordTypeList &operator<<(const KeywordTypeList &l)
    { *this += l; return *this; }

    QString toString() const
    {
        QString str("KeywordTypeList(");
        foreach(keywordTypePtr it, *this){
            if (it != NULL){
                str += it->toString()+",";
            }
        }
        str += ")";
        return str;
    }

    void traverse(IVisitor* visitor)
    {
        foreach(keywordTypePtr it, *this){
            if (it != NULL){
                it->accept(visitor, it);
            }
        }
    }
};



#endif